const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function testUpdateWarehouse() {
  try {
    // 获取一个已存在的仓库
    const warehouses = await prisma.warehouse.findMany({
      take: 1
    });
    
    if (warehouses.length === 0) {
      console.log('没有找到任何仓库，请先创建仓库');
      return;
    }
    
    const warehouse = warehouses[0];
    console.log('现有仓库信息:', warehouse);
    
    // 测试更新仓库
    const updatedWarehouse = await prisma.warehouse.update({
      where: { id: warehouse.id },
      data: {
        name: '国贸店',
        location: '公司总部',
        contact: '123456789',
        status: true,
        remarks: '主要仓库'
      }
    });
    
    console.log('更新后的仓库信息:', updatedWarehouse);
    console.log('仓库更新成功!');
  } catch (error) {
    console.error('仓库更新失败:', error);
  } finally {
    await prisma.$disconnect();
  }
}

testUpdateWarehouse(); 